/*
package com.hzk.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.hzk.pojo.Order;
import com.hzk.pojo.SeckillGoods;
import com.hzk.pojo.SeckillOrder;
import com.hzk.service.IGoodsService;
import com.hzk.service.IOrderService;
import com.hzk.service.ISeckillGoodsService;
import com.hzk.service.ISeckillOrderService;
import com.hzk.vo.GoodsVo;
import com.hzk.vo.RespBean;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component //死信队列
public class OrderDlxConsumer implements InitializingBean {
    @Autowired
    private ISeckillGoodsService iSeckillGoodsService;
    @Autowired
    private IOrderService orderService;
    @Autowired
    private IGoodsService iGoodsService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private ISeckillOrderService seckillOrderService;
    private Map<Long, Boolean> EmptyStockMap = new HashMap<>();
    private Map<Long, Integer> CountStockMap = new HashMap<>();
    */
/**
     * 监听我们的死信队列（用户秒杀成功后超时未支付-监听者）
     *//*

    @RabbitListener(queues = "mayikt_order_dlx_queue")
    public void orderConsumer(String orderId) {
        System.out.println("死信队列获取消息:" + orderId);
        if (StringUtils.isEmpty(orderId)) {

        }
        //根据id查询
        QueryWrapper<Order> wrapper = new QueryWrapper<>();
        wrapper.eq("id",orderId);
        Order order = orderService.getOne(wrapper);
        if (null == order) {
            return ;
        }
        //获取状态
        String orderStatus=order.getStatus();
        //判断未支付 , 关闭订单
        if(orderStatus.equals("未支付")){//15分钟内还未支付的订单直接失效
            order.setStatus("已取消");//已失效
            orderService.updateById(order);
            boolean update = iSeckillGoodsService.update(new UpdateWrapper<SeckillGoods>()
                    .setSql("stock_count=" + "stock_count+1")
                    .eq("goods_id", order.getUserId()));
                    //更新秒杀商品的库存
        }

        //redis删除秒杀订单缓存
        redisTemplate.delete("seckillorder:" + order.getId() + ":" + order.getGoodsId());

        //删除redis空订单的内存标记
        redisTemplate.delete("isStockEmpty:" + order.getGoodsId());


        if (CountStockMap.get(order.getGoodsId()) == 0) {//设置内存标记，
            // 插入的订单数只能是数据库里面预设的数量

            return ;
        }

        if (orderStatus.equals("已支付")){//
            SeckillOrder seckillOrder = new SeckillOrder();
            seckillOrder.setOrderId(order.getId());
            seckillOrder.setGoodsId(order.getGoodsId());
            seckillOrder.setOrderId(order.getId());
            seckillOrder.setUserId(order.getUserId());
            seckillOrderService.save(seckillOrder);
            CountStockMap.put(order.getGoodsId(), CountStockMap.get(order.getGoodsId()) - 1);
        }

    }

    @Override
    public void afterPropertiesSet() throws Exception {
        List<GoodsVo> goodsVo = iGoodsService.findGoodsVo();

        if (CollectionUtils.isEmpty(goodsVo)) {
            return;
        }
        goodsVo.forEach(goodsVo1 -> {
            CountStockMap.put(goodsVo1.getId(), goodsVo1.getStockCount());
            EmptyStockMap.put(goodsVo1.getId(), false);
        });
    }
}
*/
